const mongoUtil = require("./mongo_util")
const collectionName = "address"


function getAddressList(userid, callback) {
    const mmp = mongoUtil.getCollection(collectionName)
    console.log("mmp=", mmp);
    console.log("userid", userid);
    mmp.then(collection => {
        collection.find({
            // 'addresslist.userId': userid
            // "userAddress.addressId":userid
            'userId':userid
        }).toArray(function (err, result) {
            console.log("resultjjjj", result);
            if (result.length) {
                callback(null, result)
                // new Error()
            } else {
                callback(err ? err : {
                    reason: "该用户还没有数据"
                }, result)
            }
        })
    })
}
module.exports = {
    getAddressList
}